<template>
  <div>
    <el-breadcrumb separator-icon="ArrowRight" style="margin: 16px">
      <el-breadcrumb-item :to="{ path: '/adminHome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>评论管理</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card style="margin: 15px; min-height: calc(100vh - 111px)">
      <div style="color: black; font-size: 20px;font-weight: bolder; text-align: center;">评论列表</div>
      <div>
        <div style="margin: 40px 0;">
          <div style="margin: 10px 0">
            <el-input v-model="search" 
                      @input="filterData"
                      clearable 
                      placeholder="请输入租客ID号" 
                      prefix-icon="Search"
                      style="width: 20%"/>
            <el-button icon="Search" style="margin-left: 5px" type="primary" @click="filterData"></el-button>
            <el-button icon="refresh-left" style="margin-left: 10px" type="default" @click="reset"></el-button>

            <!-- 全选按钮及批量删除按钮 -->
            <el-checkbox v-model="isAllSelected" @change="toggleSelectAll" style="margin-left: 20px; border: 1.5px solid #ccc; padding: 5px; border-radius: 4px;">全选</el-checkbox>
            <el-button icon="Delete" style="margin-left: 20px" type="danger" @click="batchDeleteConfirm">批量删除</el-button>
          </div>
        </div>
        <!--表格-->
        <el-table v-loading="loading" :data="tableData" border max-height="705" style="width: 100%">
          <el-table-column label="租客ID" prop="tenantId" min-width="10px"/>
          <el-table-column label="房源ID" prop="houseId" min-width="10px"/>
          <el-table-column label="租客评论" prop="content"/>
          <el-table-column label="操作" width="130px">
            <template #default="scope">
              <el-popconfirm title="确认删除？" @confirm="handleDelete(scope.row.commentId)">
                <template #reference>
                  <el-button icon="Delete" type="danger">删除</el-button>
                </template>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>
        <!--分页-->
        <div style="margin: 40px 0">
          <el-pagination
              v-model:currentPage="currentPage"
              :page-size="pageSize"
              :page-sizes="[5, 10, 15]"
              :total="total"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"></el-pagination>
        </div>
      </div>
    </el-card>
  </div>
</template>
<script src="@/assets/js/CommentManagement.js"></script>
